//
//  WSViewController.m
//  WSDataReportedTool
//
//  Created by v_zjxzhen on 05/12/2021.
//  Copyright (c) 2021 v_zjxzhen. All rights reserved.
//

#import "WSViewController.h"
#import "WSDataReportWindow.h"
#import "WSDataReportDataSourceManager.h"

@interface WSViewController ()

@property (nonatomic, strong) WSDataReportWindow *dataReportWindow;
@property (nonatomic, strong) UIWindow *customWindow;

@end

@implementation WSViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    
    if (!self.dataReportWindow) {
        NSArray *listViewShowKeyArray = @[@"event_type", @"event_name", @"position", @"page_id", @"debugDate"];
        self.dataReportWindow = [[WSDataReportWindow alloc] initWithListViewShowKeyArray:listViewShowKeyArray dataFilterItemArray:[self dataFilterItemArray]];
    }
    [self.dataReportWindow showWithAnimation:YES];
    
    if (@available(iOS 13.0, *)) {
        UIWindowScene *targetWindowScene;
        for (UIScene *scene in [[UIApplication sharedApplication] connectedScenes]) {
            if (scene.activationState == UISceneActivationStateForegroundActive) {
                targetWindowScene = (UIWindowScene *)scene;
            }
        }
        self.dataReportWindow.windowScene = targetWindowScene;
    }
    
    NSLog(@"%@",[UIApplication sharedApplication].windows);
    
    [[WSDataReportDataSourceManager instance] addReportData:@{@"event_type" : @"1", @"event_name" : @"dddd", @"position" : @"video_upload", @"page_id" : @"ddd", @"debugDate" : @"2019-09-18"}];
    
}

- (NSArray<WSDataReportFilterItem *> *)dataFilterItemArray {
    NSArray *firstItemFilterDefaultList = @[@"0", @"1", @"2", @"9"];
    WSDataReportFilterItem *firstItem = [[WSDataReportFilterItem alloc] initWithFilterKey:@"event_type" withFilterDefaultList:firstItemFilterDefaultList];
    
    NSArray *secondItemFilterDefaultList = @[@"page_visit", @"user_action", @"user_exposure", @"video_upload", @"video_play"];
    WSDataReportFilterItem *secondItem = [[WSDataReportFilterItem alloc] initWithFilterKey:@"event_name" withFilterDefaultList:secondItemFilterDefaultList];
    
    NSArray *thirdItemFilterDefaultList = @[@"cameratab", @"stWSGetMaterialPageByCategroyReq",
                                            @"publish.album.sourceLoadTime", @"publisher.render.chain", @"material_download"];
    WSDataReportFilterItem *thirdItem = [[WSDataReportFilterItem alloc] initWithFilterKey:@"position" withFilterDefaultList:thirdItemFilterDefaultList];
    
    NSArray *fourItemFilterDefaultList = @[@"0", @"1", @"2", @"9"];
    WSDataReportFilterItem *fourItem = [[WSDataReportFilterItem alloc] initWithFilterKey:@"event_type" withFilterDefaultList:fourItemFilterDefaultList];
    
    return @[firstItem, secondItem, thirdItem, fourItem];

}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
